﻿--[[
    @Brief    登录模块
    @Author    jameszhai
    @Date    2017-05-16
--]]

TLoginModule = 
{
    -- 加载模块
    InitModule = function()
        -- Load QR config module
        ierd_tgp.tpf_ui.Require("wegame_login\\login_qrcode_cfg.lua");

        -- Load old module
        ierd_tgp.tpf_ui.Require("wegame_login\\tgp_model.lua");

        -- 初始化一下旧模块
        login_model.init();

        -- 检测是否网吧模式
        TLoginModule.IsNetBar();
    end;

    -- 卸载模块
    UnInitModule = function()

        if nil ~= TLoginModule.zLoginList then
            TLoginModule.zLoginList:delete();
            TLoginModule.zLoginList = nil;
        end;

        if nil ~= TLoginModule.zSavedList then
            TLoginModule.zSavedList:delete();
            TLoginModule.zSavedList = nil;
        end;

        if nil ~= TLoginModule.zMailSavedList then
            TLoginModule.zMailSavedList:delete();
            TLoginModule.zMailSavedList = nil;
        end;
    end;

    -- 获取二维码登录状态
    GetQRStatus = function()
        -- 如果二维码开关配置拉取失败，再拉取一次
        if not login_qrcode_config.is_request_send_succ then
            login_qrcode_config.init();
        end;
    end;

    -- 二维码登录是否开启
    IsQREnabled = function()
        return login_qrcode_config.show_qrcode_switch();
    end;

    -- 获取登录广告配置
    GetLoginADCfg = function()
        --TOssConfig.QueryCfg(, "TLoginModule.OnGetADCfg", true);
    end;

    -- 开始安全扫描
    StartScan = function()
        if TLoginModule.CheckLoginMgr() then
            TGPLog.LogI("LoginM", "Start scan befor login.");
            TLoginModule.pLoginMgr:ScanBeforeLogin();
        else
            TGPLog.LogE("LoginM", "Start scan, get login_mgr fail.");
        end;
    end;

    -- 启动二维码登录
    StartQRLogin = function()
        if TLoginModule.CheckLoginMgr() then
            if TLoginModule.pLoginMgr:StartQRLogin() then
                TGPLog.LogI("LoginM", "Start QR login success.");
                return true;
            else
                TGPLog.LogE("LoginM", "Start QR login fail.");
                return false;    
            end;
        else
            TGPLog.LogE("LoginM", "Start QR login, get login manager fail.");
            return false;
        end;
    end;

    -- 删除保存的帐号
    DelAccByUin = function(nUserID)
        if nil == nUserID then
            TGPLog.LogE("LoginM", "Delete account, account is null");
            return false;
        end;

        if not TLoginModule.CheckLoginMgr() then
            return false;
        end;

        local     zList = TLoginModule.GetSavedList();

        if nil == zList then
            TGPLog.LogE("LoginM", "Get save list fail.");
            return false;
        end;

        local     bFind = false;

        for nIdx = 0, zList.count - 1 do
            if zList.list[nIdx].uin == nUserID then
                bFind = true;
                break;
            end;
        end;

        if bFind then
            -- 删除记录
            TLoginModule.pLoginMgr:DeleteRecord(nUserID);

            -- 更新保存的帐号列表
            TLoginModule.UpdateSaveList();

            return true;
        else
            TGPLog.LogE("LoginM", "Account not find:" .. tostring(nUserID));
            return false;
        end;
    end;

    -- 删除保存的邮箱账号
    DelAccByMail = function(userAcc)
        if nil == userAcc then
            TGPLog.LogE("LoginM", "Delete mail account, account is null");
            return false;
        end;

        if not TLoginModule.CheckLoginMgr() then
            return false;
        end;

        local     zList = TLoginModule.GetMailSavedList();

        if nil == zList then
            TGPLog.LogE("LoginM", "Get mail save list fail.");
            return false;
        end;

        local     bFind = false;

        for nIdx = 0, zList.count - 1 do
            if zList.list[nIdx].acc_name == userAcc then
                bFind = true;
                break;
            end;
        end;

        if bFind then
            -- 请求服务删除
            local req_data = {};
            req_data["account"] = userAcc;
            comm_center.call_service("Svr_DelMailHistaryAcc", req_data);
            -- 更新保存的帐号列表
            TLoginModule.UpdateMailSaveList();

            return true;
        else
            TGPLog.LogE("LoginM", "mail Account not find:" .. userAcc);
            return false;
        end;
    end;

    -- 尝试自动登录
    TryToAutoLogin = function()
        if TLoginModule.CheckLoginMgr() then
            TLoginModule.pLoginMgr:TryAutoLogin();
        else
            TGPLog.LogE("LoginM", "Trying to auto-login, get login manager fail.");
        end;
    end;

    -- 尝试离线登录
    TryToOffLogin = function()
        if TLoginModule.IsNetBar() then
            TGPLog.LogI("LoginM", "Offline login, netbar mode, return.");
            return false;
        end;

        if TLoginModule.CheckLoginMgr() then
            local     nUserID = TLoginModule.pLoginMgr:get_offline_launch_account();

            if nil ~= nUserID and 0 ~= nUserID then
                local     zParam = {};

                zParam["account_id"] = tostring(nUserID);

                -- 标记为离线登录
                if TLoginModule.DoOfflineLogin(zParam) then
                    login_model.running_mode = login_model.OFFLINE_MODE;
                    return true;
                else
                    TGPLog.LogI("LoginM", "Offline login return fail.");
                    return false;
                end;
            else
                TGPLog.LogI("LoginM", "Try offline login, login uin invalid.");
                return false;
            end;
        else
            TGPLog.LogI("LoginM", "Try offline login, get login manager fail.");
            return false;
        end;
    end;

    -- 是否有保存密码
    IsSavedPwd = function(nUserID)
        local     zList = TLoginModule.GetSavedList();

        if nil == zList then
            return false;
        end;

        local     nTempID = tonumber(nUserID);

        for nIdx = 0, zList.count - 1 do
            if nTempID == zList.list[nIdx].uin then
                return zList.list[nIdx].saved_pwd;
            end;
        end;

        return false;
    end;

    -- 邮箱是否保存密码
    IsMailSavedPwd = function (nUserAcc)
        local zList = TLoginModule.GetMailSavedList();

        if nil == zList then
            return false;
        end;

        for nIdx = 0, zList.count - 1 do
            if nUserAcc == zList.list[nIdx].acc_name then
                return zList.list[nIdx].saved_pwd;
            end;
        end;

        return false;
    end;

    -- 是否登录过的Account
    IsLoginedAccount = function(nAccountID)
        if TLoginModule.CheckLoginMgr() then
            local zList = ierd_tgp.login_mgr.WeGamePvaInfoListPod:new();

            if (TLoginModule.pLoginMgr:GetWeGameHistoryAccount(0, zList)) then
                local     strTGPID = tostring(nAccountID);

                for nIdx = 0, zList.count - 1 do
                    if strTGPID == zList.list[nIdx].wegame_id then
                        return true;
                    end;
                end;
            else
                TGPLog.LogE("LoginM", "Get history account fail.");
            end

            zList:delete();
        end

        return false;
    end;

    -- 是否登录过的邮箱
    IsLoginMailAcc = function (userAcc)
        local     zList = TLoginModule.GetMailSavedList();

        if nil == zList then
            return false;
        end;

        for nIdx = 0, zList.count - 1 do
            if userAcc == zList.list[nIdx].acc_name then
                return true;
            end;
        end;

        return false;
    end;

    -- 是否可离线登录
    CanOfflineLogin = function()
        return TLoginModule.IsLoginedAccount(login_model.main_tgp_id);
    end;

    -- 根据用户ID获取头像
    GetIconByUin = function(nUserID)
        local     zList = TLoginModule.GetSavedList();

        if nil == zList then
            return nil;
        end;

        for nIdx = 0, zList.count - 1 do
            if nUserID == zList.list[nIdx].uin then
                return zList.list[nIdx].head;
            end;
        end;

        return nil;
    end;

    -- 取消登录
    CancelLogin = function(nSvrID, nUin)
        if TLoginModule.CheckLoginMgr() then
            TLoginModule.pLoginMgr:CancelLogin(nSvrID, nUin);
        else
            TGPLog.LogE("LoginM", "Get login manager fail.");
        end;
    end;

    -- 检查是否保存密码
    CheckSavePwd = function(nOption)
        if nil ~= nOption then
            login_model.pwd_saved = (1 == nOption) or (3 == nOption);
        else
            login_model.pwd_saved = false;
        end;
    end;

    -- 快速登录
    QuickLogin = function(nUserID)
        if TLoginModule.CheckLoginMgr() then
            TLoginModule.CheckSavePwd(nil);
            TGPLog.LogI("LoginM", "Quick login: " .. tostring(nUserID));
            TLoginModule.pLoginMgr:QuickLogin(tostring(nUserID));
            return true;
        else
            return false;
        end;
    end;

    -- 历史帐号登录
    --[[
        nUserID -- int, 帐号
        nOption -- int, 记住密码(1)，自动登录(2)
    --]]
    LoginByHistory = function(nUserID, nOption)
        if TLoginModule.CheckLoginMgr() then
            TGPLog.LogI("LoginM", "History login, account:" .. tostring(nUserID) ..
                        " Option:" .. tostring(nOption));

            TLoginModule.CheckSavePwd(nOption);

            if nil ~= nOption then
                return TLoginModule.pLoginMgr:LoginByHistory(nOption, tonumber(nUserID));
            else
                return TLoginModule.pLoginMgr:LoginByHistory(0, tonumber(nUserID));
            end;
        else
            return false;
        end;
    end;

    -- 根据TEdit登录
    --[[
        sUsrAcc -- string, 帐号
        nOption -- int, 记住密码，自动登录
    --]]
    LoginByTedit = function(sUserID, nOption)
        if TLoginModule.CheckLoginMgr() then
            TGPLog.LogI("LoginM", "Login by TEdit:"..sUserID);
            TLoginModule.CheckSavePwd(nOption);
            return TLoginModule.pLoginMgr:LoginByTedit(tonumber(nOption), sUserID);
        else
            return false;
        end;
    end;

    LoginByMail = function (subType, sUserID, sPWD, nOption)
        if TLoginModule.CheckLoginMgr() then
            TGPLog.LogI("LoginM", "Login by TEdit:"..sUserID);
            TLoginModule.CheckSavePwd(nOption);
            -- return TLoginModule.pLoginMgr:LoginByTedit(tonumber(nOption), sUserID);
            local req_data = {};
            req_data["option"] = tonumber(nOption);
            req_data["account"] = sUserID;
            req_data["sub_type"] = subType;
            req_data["pwd"] = sPWD;
            comm_center.call_service("Svr_LoginByMail", req_data);
        else
            return false;
        end; 
    end;

    -- 获取快速登录帐号列表
    GetQuickAccList = function()
        if (nil == TLoginModule.zLoginList) then
            TLoginModule.zLoginList = ierd_tgp.login_mgr.PvaInfoListPod:new();
        end;

        if (TLoginModule.zLoginList.count <= 0) and TLoginModule.CheckLoginMgr() then
            if (TLoginModule.pLoginMgr:GetPvaList(TLoginModule.zLoginList)) then
            	TGPLog.LogI("LoginM", 
                    "Get logined account success, count"..TLoginModule.zLoginList.count);
            else
                TGPLog.LogE("LoginM", "Get logined account fail.");
            end;
        end;

        return TLoginModule.zLoginList;
    end;

    -- 获取历史帐号列表
    GetSavedList = function()
        TLoginModule.UpdateSaveList();
        return TLoginModule.zSavedList;
    end;

    -- 更新保存的列表
    UpdateSaveList = function()
        if TLoginModule.CheckLoginMgr() then
            if nil == TLoginModule.zSavedList then
                TLoginModule.zSavedList = ierd_tgp.login_mgr.PvaInfoListPod:new();
            end;

            if (TLoginModule.pLoginMgr:GetHistoryAccount(TLoginModule.zSavedList)) then
                TGPLog.LogI("LoginM", "Get history account success.");
                return true;
            else
                TGPLog.LogE("LoginM", "Get history account fail.");
                return false;
            end;
        else
            return false;
        end;
    end;

    -- 获取邮箱历史帐号列表
    GetMailSavedList = function()
        TLoginModule.UpdateMailSaveList();
        return TLoginModule.zMailSavedList;
    end;

    -- 更新保存的列表
    UpdateMailSaveList = function()
        if TLoginModule.CheckLoginMgr() then
            if nil == TLoginModule.zMailSavedList then
                TLoginModule.zMailSavedList = ierd_tgp.login_mgr.WeGamePvaInfoListPod:new();
            end;

            if (TLoginModule.pLoginMgr:GetWeGameHistoryAccount(TLoginModule.WGA_USER_TYPE_EMAIL, TLoginModule.zMailSavedList)) then
                TGPLog.LogI("LoginM", "Get mail history account success.");
                return true;
            else
                TGPLog.LogE("LoginM", "Get mail history account fail.");
                return false;
            end;
        else
            return false;
        end;
    end;


    -- 获取当前正在登录的帐号信息
    GetCurInfo = function()
        return TLoginModule.zLoginInfo;
    end;

    -- 保存当前登录的帐号的信息
    SetCurInfo = function(zParam)
        TLoginModule.zLoginInfo = zParam;
    end;

    SetCurUin = function(nCurUin)
        login_model.current_uin = nCurUin;
    end;

    GetCurUin = function()
        return login_model.current_uin;
    end;

    -- Set current login uin
    SetLoginUin = function(nUin)
        TLoginModule.nLoginUin = nUin;
        login_model.main_uin   = nUin;
    end;

    -- 获取当前登录的UIN
    GetLoginUin = function()
        return TLoginModule.nLoginUin;
    end;

    SetTGPID = function(tgp_id)
        login_model.main_tgp_id = tgp_id;
    end;

    GetTGPID = function()
        return login_model.main_tgp_id;
    end;

    SetLoginAccountType = function(account_type)
       TLoginModule.nAccountType = account_type;
    end;

    GetLoginAccountType = function()
        return TLoginModule.nAccountType;
    end;

    -- WeGame服务器状态
    SetSvrState = function(nState)
        TLoginModule.nWGSvrStat = nState;
    end;

    -- WeGame服务器状态
    GetSvrState = function()
        return TLoginModule.nWGSvrStat;
    end;

    GetShowFailTips = function()
        return TLoginModule.bTipsShown;
    end;

    SetShowFailTips = function(bShow)
        TLoginModule.bTipsShown = true;
    end;

    -- TVersion是否已经回包
    SetTVerHasRsp = function(bResp)
        TLoginModule.bTVerResp = bResp;
    end;

    -- TVersion是否已经回包
    GetTVerHasRsp = function()
        return TLoginModule.bTVerResp;
    end;

    SetCanLogin = function(bCan)
        TLoginModule.bTCanLogin = bCan;
    end;

    GetCanLogin = function()
        return TLoginModule.bTCanLogin;
    end;

    CheckLoginMgr = function()
        if nil ~= TLoginModule.pLoginMgr then
            return true;
        end;

        TLoginModule.pLoginMgr = base_utility.get_component_adapter("ILogin_mgr",
                            "ierd_tgp.login_mgr.GetLoginMgr();");

        if nil ~= TLoginModule.pLoginMgr then
            return true;
        else
            TGPLog.LogE("LoginM", "Get login manager fail.");
            return false;
        end;
    end;

    -- 是否是网吧模式
    IsNetBar = function()
        if nil == TLoginModule.bIsNetBar then
            local pGMLib = base_utility.get_component_adapter("IGame_library",
                    "ierd_tgp.game_library.Get_game_library_adapter();");

            if nil == pGMLib then
                TGPLog.LogE("LoginM", "Check is netbar, get game_library fail.");
                return false;
            end;

            local nChnlID = pGMLib:get_bind_channel_id();

            if 1 == nChnlID then
                TLoginModule.bIsNetBar = true;
            else
                TLoginModule.bIsNetBar = false;
            end;

            -- Load old module
            login_model.netbar_mode = TLoginModule.bIsNetBar;
        end;

        return TLoginModule.bIsNetBar;
    end;

    -- 设置登录失败信息
    SetFailInfo = function(bFail, zInfo)
        TLoginModule.bLoginFail = bFail;
        TLoginModule.zFailInfo  = zInfo;
    end;
    
    -- 获取登录失败的信息
    GetFailInfo = function()
        return TLoginModule.zFailInfo;
    end;

    -- 是否有登录失败
    IsLoginFail = function()
        return TLoginModule.bLoginFail;
    end;

    -- 更新验证码
    UpdatePict = function(nSvrID)
        if TLoginModule.CheckLoginMgr() then
            TLoginModule.pLoginMgr:RenewPic(nSvrID);
        else
            TGPLog.LogE("LoginM", "Update picture, check loginmgr fail.");
        end;
    end;

    -- 验证码验证
    ValidPict = function(nSvrID, sCode)
        if TLoginModule.CheckLoginMgr() then
            TLoginModule.pLoginMgr:VerifyByPic(nSvrID, sCode);
        else
            TGPLog.LogE("LoginM", "Update picture, check loginmgr fail.");
        end;
    end;

    -- 通知登录关闭
    NotifyClose = function()
        TLoginModule.bIsWGLogin = false;

        if TLoginModule.CheckLoginMgr() then
            TLoginModule.pLoginMgr:InformLoginWindowClosed();
        else
            TGPLog.LogE("LoginM", "Notify close, get login manager fail.");
        end;
    end;

    -- 保存IM数据
    SetIMData = function(nLevel, nInviteCnt)
        -- 0 -- 普通用户， 1 -- 灰度一级用户， 2 --灰度二级用户
        login_model.social_user_level = nLevel;
        login_model.social_invite_code_count = nInviteCnt;
    end;

    -- 是否为WEGame登录
    IsWeGameLogin = function()
        return TLoginModule.bIsWGLogin;
    end;

    -- 重启WEGAME
    RestartWG = function()
        if TLoginModule.CheckLoginMgr() then
            TLoginModule.pLoginMgr:RestartTGP();
        else
            TGPLog.LogE("LoginM", "Restart WG, Login manger is null.");
        end;
    end;

    -- 是否隐藏登录
    IsHideLogin = function()
        if nil == TLoginModule.bHideQLogin then
            if TLoginModule.CheckLoginMgr() then
                TLoginModule.bHideQLogin = TLoginModule.pLoginMgr:IsHideQuickLogin();
            else
                TGPLog.LogE("LoginM", "IsHideQuickLogin, Login manger is null.");
            end;
        end;

        return TLoginModule.bHideQLogin;
    end;

    -- 获取在线时常
    GetOnlineTime = function()
        if TLoginModule.CheckLoginMgr() then
            TLoginModule.pLoginMgr:GetProgramAliveTime();
        else
            TGPLog.LogE("LoginM", "Query online tim, get login manager fail.");
            return 0;
        end;
    end;

    -- 设置登录广告
    SetLoginAD = function(zData)
        TLoginModule.login_ad_data = zData;
    end;

    GetLoginAD = function()
        return TLoginModule.login_ad_data;
    end;

    -- 是否离线启动
    IsOfflineLaunch = function()
        if TLoginModule.IsNetBar() then
            TGPLog.LogI("LoginM", "NetBar mode, do not start offline mode.");
            return false;
        end;

        -- 是否离线启动
        if TLoginModule.CheckLoginMgr() then
            return TLoginModule.pLoginMgr:is_offline_launch();
        else
            TGPLog.LogE("LoginM", "Get offline launcher, get login manger fail.");
            return false;
        end;
    end;

    -- 离线模式登录
    DoOfflineLogin = function(zParam)
        if (nil ~= zParam) and (nil ~= zParam.account_id) and (0 ~= zParam.account_id) then
            if TLoginModule.IsLoginedAccount(zParam.account_id) then
                TGPLog.LogI("LoginM", "Offline login, login Account:".. tostring(zParam.account_id));
                comm_center.call_service("Svr_OfflineLogin", zParam);
                return true;
            else
                TGPLog.LogI("LoginM", "Offline login, account not login: " .. tostring(zParam.account_id));
                return false;
            end;
        else
            TGPLog.LogE("LoginM", "Offline login, param error.");
            return false;
        end;
    end;

    -- 离线模式是否开启
    IsOfflineEnable = function()
        if TLoginModule.IsNetBar() then
            return false;
        end;

        local zCfg = comm_center.call_service("Svr_IsOfflineOpen", {});

        if (nil ~= zCfg) and (0 ~= zCfg["open"]) then
            TLoginModule.bOffLnOpen = true;
        end;

        return TLoginModule.bOffLnOpen;
    end;

    -- 设置是否是黑机器
    SetBlcakMachineState = function(bBlackMachine)
        TLoginModule.bBlcakMachine = bBlackMachine;
    end;

    -- Get是否是黑机器
    GetBlackMachineState = function()
        return TLoginModule.bBlcakMachine;
    end;

    -- 设置黑机器警告文本
    SetBlackMachineAlertText = function(sAlertText)
        TLoginModule.strBlcakMachineAlert = sAlertText;
    end;

    GetBlackMachineAlertText = function()
        return TLoginModule.strBlcakMachineAlert;
    end;

    -- 创建TEDIT
    CreateTEdit = function(hWindow)
        if TLoginModule.bHasTEdit then
            TGPLog.LogI("LoginM", "TEdit already created.");
            return true;
        end;

        if not TLoginModule.CheckLoginMgr() then
            TGPLog.LogE("LoginM", "Create TEDIT, Get login manager fail.");
            return false;
        end;

        --[[
        local     zParam = {};

        zParam["screen"] = true;

        local     zRtn  = comm_center.call_service("Svr_GetLoginRect", zParam);

        if nil == zRtn then
            TGPLog.LogE("LoginM", "Get login window return null.");
            return false;
        end;

        local     rtWnd = zRtn["rect"];

        if nil == rtWnd then
            TGPLog.LogE("AccLogin", "Get window rect fail.");
            return false;
        end;

        zTemp.x       = rtEdit.left - rtWnd.left + 42;
        zTemp.y       = rtEdit.top  - rtWnd.top  + 4;
        zTemp.width   = rtEdit.right  - rtEdit.left - 60;
        zTemp.height  = rtEdit.bottom - rtEdit.top - 2 - 8;
        ]]
        local     zTemp  = ierd_tgp.login_mgr.TEditParamPod:new();

        zTemp.parent_hwnd = hWindow;
        zTemp.game_id = GAME_ID.GAME_ID_TGP;

        zTemp.st_txt_color.r = 162;
        zTemp.st_txt_color.g = 162;
        zTemp.st_txt_color.b = 162;

        zTemp.st_txt_tip_color.r = 160;
        zTemp.st_txt_tip_color.g = 160;
        zTemp.st_txt_tip_color.b = 160;

        if base_utility.CLIENT_TYPE.OVERSEA_VER == base_utility.get_client_version_type() then
            zTemp.x 	 = 650;
	        zTemp.y 	 = 233;
	        zTemp.width  = 184;
	        zTemp.height = 22;
        else
            zTemp.x 	 = 696;
	        zTemp.y 	 = 233;
	        zTemp.width  = 128;
	        zTemp.height = 22;

            zTemp.st_bg_color.r = 55;
            zTemp.st_bg_color.g = 55;
            zTemp.st_bg_color.b = 57;
        end
        --zTemp.st_txt_selected_color = 16777215;
        --zTemp.st_bg_selected_color = 0;

        TLoginModule.bHasTEdit = TLoginModule.pLoginMgr:CreateTedit(zTemp);
        zTemp:delete();

        return TLoginModule.bHasTEdit;
    end;

    -- 销毁TEDIT
    DestroyTEdit = function()
        if TLoginModule.bHasTEdit then
            if not TLoginModule.CheckLoginMgr() then
                TGPLog.LogE("LoginM", "Create TEDIT, Get login manager fail.");
                return false;
            end;
            -- 由C++底层进行销毁
            TLoginModule.bHasTEdit = false;
        end;
    end;

    -- 显示TEdit
    ShowTEdit = function(bShow)
        if TLoginModule.bHasTEdit then
            if not TLoginModule.CheckLoginMgr() then
                TGPLog.LogE("LoginM", "Get login manager fail.");
                return;
            end;

            TLoginModule.pLoginMgr:ShowTedit(bShow);
        else
            TGPLog.LogI("LoginM", "TEdit not created.");
        end;
    end;

    -- 是否有TEDIT
    HasTEdit = function()
        return TLoginModule.bHasTEdit;
    end;

    GetAccountType = function ()
        local accType = TLoginModule.LOGIN_ACCOUNT_TYPE.KQQLogin;
        local getAccType = comm_center.call_service("Svr_GetAccountType", {});
        if nil ~= getAccType then
            accType = getAccType.account_type;
        end
        return accType;
    end;

    GetCurLoginArea = function ()
        -- 通过服务获取
        local is_cn_zone = comm_center.call_service("Svr_IsCNZoneByIP", {});
        local area_type = TLoginModule.LOGIN_AREA_TYPE.kChina;
        if is_cn_zone.is_cn_zone ~= 1 then
            area_type = TLoginModule.LOGIN_AREA_TYPE.kOversea;
        end
        return TLoginModule.LOGIN_AREA_TYPE.kChina;
    end;

    LOGIN_ACCOUNT_TYPE = {
        kQQLogin = 0,       -- QQ登录
        KWeChatLogin = 1,  -- 微信登录
        KGoogleLogin = 2,  -- googel登录
        KFacebookLogin = 3,  --  Facebook登录  
        KQQOpenLogin = 4,    -- QQ open体系登录
        KQGameLogin = 5,
        KMailLogin = 6,     -- 邮箱账号登录   
        KPhoneLogin = 7,    -- 手机号登录
        KWeiboLogin = 8,    -- 微博登录
        KTouristLogin = 255,  -- 游客身份登录
    };

    LOGIN_AREA_TYPE = {
        kChina = 0,
        kOversea = 1,
    };

    MAIL_LOGIN_SUB_TYPE = {
        kByEdit = 0,     -- tas控件     
        kByPSW = 1,      -- 无tas控件输入密码
        kBySavedAcc = 2, -- 历史账号登录
    };

    WGA_USER_TYPE_EMAIL = 7,        -- SDK邮箱账户类型

    -- 是否已经创建TEDIT
    bHasTEdit  = false;

    -- 登录错误
    bLoginFail = false;
    zFailInfo  = nil;
    bHideQLogin= nil;

    -- 帐号信息
    zLoginList = nil;        -- 可以快速登录的帐号列表
    zSavedList = nil;        -- 历史帐号
    zMailSavedList = nil;   -- 邮箱历史账号

    -- 当前状态
    nLoginUin  = 0;            -- 当前登录的UIN
    zLoginInfo = nil;        -- 当前正在尝试登录的帐号信息
    nAccountType = 0;

    nWGSvrStat = 0;            -- 服务器状态
    bTipsShown = false;        -- 是否已经显示过服务器异常TIPS

    bTVerResp  = false;        -- TVersion是否有回包
    bTCanLogin = true;        -- TVersion返回是否可登录

    bIsNetBar  = nil;        -- 是否为网吧
    bIsWGLogin = true;        -- 是否为WEGAME登录
    bOffLnOpen = nil;        -- 离线模式是否开启

    -- 登录管理
    pLoginMgr  = nil;

    -- 黑机器相关
    bBlcakMachine = false;      -- 当前机器是否是黑机器
    strBlcakMachineAlert = "";  -- 黑机器显示的警告信息

    eCurLoginType = 0;
};